package com.dhecp.project.logstics.service.impl;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.dhecp.core.constant.DataFiltering;
import com.dhecp.core.utils.PageUtils;
import com.dhecp.project.common.service.impl.BaseModuleServiceImpl;
import com.dhecp.project.logstics.domain.FbaCancel;
import com.dhecp.project.logstics.mapper.FbaCancelMapper;
import com.dhecp.project.logstics.service.FbaCancelService;
import com.dhecp.project.system.service.SysDictionaryForFieldService;

/**
 * 头程取消单 服务层
 * @Author fxz
 * @Date 2023/9/1
 */
@Service
public class FbaCancelServicelmpl extends BaseModuleServiceImpl implements FbaCancelService {

    @Autowired
    private FbaCancelMapper fbaCancelMapper;

    @Autowired
    private SysDictionaryForFieldService dictionaryForFieldService;






    /**
     * 头程取消单列表
     * @param params
     * @return
     * @throws Exception
     */
    @Override
    public List<FbaCancel> queryList(Map<String, Object> params) throws Exception {
        //特殊字段商品编码修改查询详情有关联的数据
        if (params.get("CommodityCode") != null && !params.get("CommodityCode").equals("")){
            params.put("commodityCode1",params.get("CommodityCode"));
            params.put("CommodityCode","");
        }
        params.put(DataFiltering.TABLE_ALIAS, "t1");	//查询表别名
        params.put(DataFiltering.DATA_WHERE, dictionaryForFieldService.getWhereStr(params));	//常规查询条件SQL语句
        params.put(DataFiltering.DATA_SCODE, dictionaryForFieldService.getDataScode(params));	//数据权限查询条件SQL语句

        if (params.get("field") == null || params.get("field") == ""){
            String orderBy = "createTime DESC";
            PageUtils.startPageOrder(orderBy);
        }else{
            PageUtils.startPage();
        }

        return fbaCancelMapper.select(params);
    }

    @Override
    public FbaCancel queryFirstRecord(Map<String, Object> params) throws Exception {
        params.put(DataFiltering.TABLE_ALIAS, "t1");    //查询表别名
        params.put(DataFiltering.DATA_SCODE, dictionaryForFieldService.getDataScode(params));    //数据权限查询条件SQL语句
        return fbaCancelMapper.selectFirstRecordByNid(params);
    }
}
